from flask import Flask, request, make_response
from wsgiref.simple_server import make_server
from flask_cors import CORS
app = Flask(__name__)
CORS(app, supports_credentials=True)


@app.route('/queryName', methods=['GET'])
def queryName():
    username = request.args.get("username")
    password = request.args.get("username")
    print(username)
    return username


@app.after_request
def af_request(resp):
    """
    #请求钩子，在所有的请求发生后执行，加入headers。
    :param resp:
    :return:
    """
    resp = make_response(resp)
    resp.headers['Access-Control-Allow-Origin'] = '*'
    resp.headers['Access-Control-Allow-Methods'] = 'GET,POST'
    resp.headers['Access-Control-Allow-Headers'] = 'x-requested-with,content-type'
    return resp


if __name__ == "__main__":
    server = make_server('0.0.0.0', 8585, app=app)
    server.serve_forever()

